package com.acme.bankapp.domain;

public class CheckingAccount extends AbstractAccount {

	private double overdraft;
	
	public CheckingAccount(final double amount, final double overdraft) {
		super(amount);
		this.overdraft = overdraft;
	}

	
	public void deposit(double amount) {
		balance += amount;
	}

	public void withdraw(double amount) {
		if (balance >= amount) {
			balance -= amount;
		} else {
			assert (balance + overdraft > amount);
			overdraft -= amount - balance;
			balance = 0;
		}
	}
	public double maximumAmountToWithdraw() {
		return balance + overdraft;
	}
}
